package com.fac.controller.user;

import com.fac.dto.PaymentCreateDTO;
import com.fac.dto.PaymentPageQueryDTO;
import com.fac.result.PageResult;
import com.fac.result.Result;
import com.fac.service.PaymentRecordService;
import com.fac.vo.PaymentCreateVO;
import com.fac.vo.PaymentVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

/**
 * 用户端支付Controller
 */
@RestController("userPaymentController")
@RequestMapping("/user/payments")
@Api(tags = "用户端-支付接口")
@Slf4j
public class PaymentController {

    @Autowired
    private PaymentRecordService paymentRecordService;

    /**
     * 创建支付订单
     */
    @PostMapping
    @ResponseStatus(HttpStatus.CREATED)
    @ApiOperation("创建支付订单")
    public Result<PaymentCreateVO> create(@RequestBody PaymentCreateDTO createDTO) {
        log.info("创建支付订单：{}", createDTO);
        PaymentCreateVO vo = paymentRecordService.create(createDTO);
        return Result.success(vo);
    }

    /**
     * 查询支付记录
     */
    @GetMapping
    @ApiOperation("查询支付记录")
    public Result<PageResult> page(PaymentPageQueryDTO queryDTO) {
        log.info("查询支付记录：{}", queryDTO);
        PageResult pageResult = paymentRecordService.pageQuery(queryDTO);
        return Result.success(pageResult);
    }
} 